angular.module("Horizon").directive('domDone',["$timeout",function($timeout){
    return{
        restrict:'A',
//      template:'<div>Hi there</div>',
        replace:true,
		link:function(scope,elm,attrs){
			var oFoot=document.querySelectorAll(".foot")[0];
			var date=new Date();
			oFoot.style.display="none";
			if (scope.$last===true){
				oFoot.style.display="block";
				var oBody=document.querySelectorAll("body")[0];
				var oBodyHeight=oBody.clientHeight;
				var oContent=document.querySelectorAll(".content")[0];
				var oContentHeight=oContent.clientHeight;
				var oSide=document.querySelectorAll(".side")[0];
				oSide.style.display="block";
				if(oContentHeight>oBodyHeight){
					oFoot.style.top=oContentHeight+"px";
				}else{
					oFoot.style.top=oBodyHeight-30+"px";
				}
				var oRoomID=document.querySelectorAll(".mouseCopy");
				var clipboard=new Clipboard('.btn');
				var oCopy=document.querySelectorAll("#copyInfo")[0];
				$timeout(function(){
					for(var i=0;i<oRoomID.length;i++){
						oRoomID[i].onclick=function(){
			    			var oCopy=document.querySelectorAll("#copyInfo")[0];
							oCopy.style.top=$(this)[0].offsetTop+78+"px";
							oCopy.style.left=$(this)[0].clientWidth+"px";
							oCopy.style.display="block";
							$timeout(function(){
					    		oCopy.style.display="none";
					    	},1000);
						}
	//					oRoomID[i].onmouseleave=function(){
	//		    			var oCopy=document.querySelectorAll("#copyInfo")[0];
	//						oCopy.style.display="none";
	//					}
					}
				},0);
			}
		}
    };
}]);